package com.quarantine.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;

import com.quarantine.dao.trendsDao;
import com.quarantine.model.trends;
@Component
@Transactional
public class TrendsManager {
	
	private trendsDao trendsDao;

	public trendsDao getTrendsDao() {
		return trendsDao;
	}
	@Autowired
	public void setTrendsDao(trendsDao trendsDao) {
		this.trendsDao = trendsDao;
	}
	
	
	/***
	 * 保存
	 */
	
	public void save(trends entity) {
		trendsDao.save(entity);
		
	}
	    /**
	     * 根据id查找
	     */
	    @Transactional  
		public trends getById(String id) {
			return trendsDao.findUniqueBy("id", id);
		}
	    
	    /***
	     * 显示后台分会动态列表
	     * @param page
	     * @return
	     */
	    @Transactional 
	    public Page<trends> getList(final Page<trends>page ) {
		return trendsDao.findPage(page, "from trends order by edit_time desc");
	}
	    /***
	     * 显示前台分会动态列表
	     * @param page
	     * @return
	     */
	    @Transactional 
	    public Page<trends> getList1(final Page<trends>page ) {
		return trendsDao.findPage(page, "from trends order by input_time desc");
	}
	
	    @Transactional      
	    /**
	     * 根据id来删除
	     */
	    public void delete(String id){
	    	trendsDao.delete(id);
	    }
	
}
